--暗示潜埋
local anshiqianmai = fk.CreateSkill {
    name = "mcdh_anshiqianmai",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

anshiqianmai:addEffect('viewas',{
    pattern = "jink",
    interaction = function(self,player)
        local card = Fk:cloneCard("jink")
        if (Fk.currentResponsePattern == nil and player:canUse(card)) or
                (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(card)) then
            return UI.ComboBox { choices = { "jink" } }
        end
    end,
    card_filter = Util.FalseFunc,
    view_as = function(self)
        if not self.interaction.data then return end
        local card = Fk:cloneCard(self.interaction.data)
        card.skillName = self.name
        return card
    end,
    enabled_at_play = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
                and not player:isKongcheng()
    end,
    enabled_at_response = function(self, player, response)
        return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
                and not player:isKongcheng()
    end,
})

anshiqianmai:addEffect(fk.CardUseFinished,{
    can_trigger = function(self, event, target, player, data)
        if player ~= target or player.dead
                or not table.contains(data.card.skillNames, self.name) then
            return false
        end
        return player:getHandcardNum() > player.room.current:getHandcardNum()
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:askForDiscard(
                player,
                1, 1,
                true,
                self.name,
                false,
                ".",
                "#mcdh_anshiqianmai-discard:" .. room.current.id
        )
    end,
})

anshiqianmai:addEffect(fk.CardRespondFinished,{
    can_trigger = function(self, event, target, player, data)
        if player ~= target or player.dead
                or not table.contains(data.card.skillNames, self.name) then
            return false
        end
        return player:getHandcardNum() > player.room.current:getHandcardNum()
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:askForDiscard(
                player,
                1, 1,
                true,
                self.name,
                false,
                ".",
                "#mcdh_anshiqianmai-discard:" .. room.current.id
        )
    end,
})


Fk:loadTranslationTable {
    ["mcdh_anshiqianmai"] = "伏语",
    [":mcdh_anshiqianmai"] = "『暗示潜埋』<br>每回合限一次，若你有手牌，你可以视为使用或打出【闪】，然后若你的手牌数大于当前回合角色，你弃置一张牌。",
    ["#mcdh_anshiqianmai-discard"] = "暗示潜埋:因为你的手牌数大于 %src ，你需要弃置一张牌",
}

return anshiqianmai